<template>
  <!--登陆表单容器-->
  <div class="login_container">
    <!--    登录表单区域-->
    <div class="login_box">
      <!--      头像-->
      <div class="avatar_box">
        <!--        <img src="../assets/img/1.png">-->
      </div>
      <!--      表单-->
      <div style="height100%;width: 80%;margin: 50px -20px;padding: 40px 0px">
        <el-form :model="loginForm" :rules="loginRules" ref="loginForm" label-width="100px" class="login_Form">
          <el-form-item label="用户名" prop="username">
            <el-input prefix-icon="el-icon-user" v-model="loginForm.username"></el-input>
          </el-form-item>
          <el-form-item label="密码" prop="password">
            <el-input prefix-icon="el-icon-lock" v-model="loginForm.password"></el-input>
          </el-form-item>
          <el-form-item label="验证码" prop="verifyCode">
            <div class="verify">
              <el-input prefix-icon="el-icon-mobile-phone" v-model="loginForm.verifyCode"
                        class="verify_code"></el-input>
              <img src="../assets/img/img.png" class="verify_img"></img>
            </div>
          </el-form-item>
          <el-form-item class="login_btn">
            <el-button type="primary" @click="submitForm('loginForm')">立即创建</el-button>
            <el-button @click="resetForm('loginForm')">重置</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Login',
  data () {
    return {
      loginForm: {
        username: '',
        password: '',
        verifyCode: '',
      },
      loginRules: {
        username: [
          {
            required: true,
            message: '请输入用户名',
            trigger: 'blur'
          },
          {
            min: 1,
            max: 9,
            message: '长度在 1 到 9 个字符',
            trigger: 'blur'
          }
        ],
        password: [
          {
            required: true,
            message: '请输入密码',
            trigger: 'blur'
          },
          {
            min: 1,
            max: 9,
            message: '长度在 1 到 9 个字符',
            trigger: 'blur'
          }
        ],
        verifyCode: [
          {
            required: true,
            message: '请输入验证码',
            trigger: 'blur'
          },
        ],
      }
    }
  },
  methods: {
    submitForm (formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.$router.push("/main");
          // alert('submit!')
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    resetForm (formName) {
      this.$refs[formName].resetFields()
    }
  }
}
</script>

<style scoped>
.login_container {
  height: 100%;
  background-color: lightblue;

}

.login_box {
  width: 450px;
  height: 380px;
  background-color: #ffffff;
  border-radius: 3px; /*边框*/
  position: absolute; /*绝对定位*/
  /*移动定位*/
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);

.avatar_box {
  width: 130px;
  height: 130px;
  border: 1px solid #eeeeee;
  border-radius: 50%;
  padding: 10px;
  margin: -65px auto; /*居中*/
  background-color: #ffffff;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1); /*element中的阴影样式*/
}

.img {
  width: 10%;
  height: 10%;
  border-radius: 50%;
  background-color: #EEEEEEE;
}

}


.login_Form {
  position: absolute;
  /*bottom: 0px;*/
  width: 100%;
  height: 100%;

}

.login_btn {
  display: flex;
  justify-content: flex-end;
}

.verify_code {
  width: 60%;

}

.verify_img {
  background-size: contain;
  width: 40%;
}

.verify {
  display: flex;
  justify-content: center;
}

/*.verify {*/
/*  display: flex;*/

/*.verify_code {*/
/*  width: 70%;*/
/*  justify-content: left;*/
/*}*/

/*.verify_img {*/
/*  justify-content: flex-end;*/
/*  width: 30%;*/
/*  height: 45px;*/
/*}*/

/*}*/
</style>
